<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="cn">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.0.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.0.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.0.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.0.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.0.0" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="categories">
<meta property="og:url" content="http://yoursite.com/categories/index.html">
<meta property="og:site_name" content="hill&#39;s blog">
<meta property="og:locale" content="cn">
<meta property="article:published_time" content="2017-07-10T08:36:26.000Z">
<meta property="article:modified_time" content="2021-02-25T04:04:48.836Z">
<meta property="article:author" content="heyaojia">
<meta name="twitter:card" content="summary">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '6.0.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/categories/"/>





  <title>hill's blog</title>
  








<meta name="generator" content="Hexo 4.2.1"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="cn">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"> <div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">hill's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/02/25/whoami/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/02/25/whoami/" itemprop="url">WHOAMI</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-02-25T12:04:48+08:00">2021-02-25</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <blockquote class="blockquote-center"><p> ERLANG游戏狗</p>
<p>Golang学习狗</p>
<p>C++回锅肉  </p>
<p>JAVA梦中回顾  </p>
<p>数据库雪崩高手  </p>
<p>Python一说就会  </p>
<p>PHP是世界上最好的语言（可惜我不会）  </p>
<p>Linux rm -rf 大师  </p>
<p>算法界卢本伟  </p>
<p>游戏行业吴亦凡  </p>
<p>著名九游运营林小姐的老公  </p>
</blockquote><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/05/08/Mysql/MYSQL-%E7%B4%A2%E5%BC%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/05/08/Mysql/MYSQL-%E7%B4%A2%E5%BC%95/" itemprop="url">Mysql/MYSQL-索引</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-05-08T10:37:23+08:00">2021-05-08</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="MYSQL-索引"><a href="#MYSQL-索引" class="headerlink" title="MYSQL - 索引"></a><strong><em>MYSQL</em></strong> - 索引</h3><hr>
<h5 id="一、索引基本概述"><a href="#一、索引基本概述" class="headerlink" title="一、索引基本概述"></a><strong>一、索引基本概述</strong></h5><p>​        众所周知，索引是<strong><em>Mysql</em></strong>中很重要的一个系统。如果没有索引的存在，那么我们在查询数据的时候，必须得整表遍历，直至找到对应数据。那么一个既要在时间复杂度和空间复杂的度都快速的索引系统设计，是至关重要的。本文目的是为了详细搞懂索引的相关原理，以及实际业务场景中的一些问题。</p>
<h5 id="二、索引原理"><a href="#二、索引原理" class="headerlink" title="二、索引原理"></a><strong>二、索引原理</strong></h5><p><strong><em>|1. 相关概念（操作系统）</em></strong></p>
<ol>
<li><p>计算机操作系统中局部性原理</p>
<p>​    <img src="https://pic1.zhimg.com/80/v2-1d4036e0bf980a34f94d6ab414f3ae17_720w.jpg?source=1940ef5c" alt="图来自知乎"></p>
<p>​    按照上图操作系统存储速度对照表，数据是放在越上层运行速度越快，同时容量也越小，所以这少不了不同层数之间会存在数据交换。CPU从缓存读取数据读取不到的时候（缓存未命中），会k + 1层去获取数据，直到最后一层，这样大大降低了CPU的效率，所以在编写程序的时候，具有局部性原理的数据，会更有效率。程序都有聚集成群的倾向，分为空间局部性和时间局部性：</p>
<ol>
<li><p>时间局部性原理</p>
<p>​    <code>同一内存地址，多次被访问到，称之为时间局部性</code></p>
</li>
<li><p>空间局部性原理</p>
<p>​    <code>如果一个内存地址被引用后，与他相邻的附近的内存地址也被引用了，这就是空间局部性原理</code></p>
</li>
</ol>
<ul>
<li><a href="https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array" target="_blank" rel="noopener">stackoverflow关于代码中有序Array和无序数组的局部性</a></li>
<li><a href="https://www.zhihu.com/question/25142664" target="_blank" rel="noopener">知乎中关于局部性原理的讨论</a></li>
</ul>
</li>
<li><p>磁盘预读</p>
<p>​    内存跟磁盘交互的时候保证每次读取一个逻辑单位，这个逻辑单位叫做页，或者叫page，一般都是4k或者8k，在进行读取的时候都是4K的整数倍，InnoDB一次读取16KB的数据。</p>
</li>
</ol>
<p><strong><em>|2. Mysql索引的数据结构</em></strong></p>
<ul>
<li>思考: 降低I/O的方式有以下两个方面<ul>
<li>I/O次数</li>
<li>I/O读取的量级</li>
</ul>
</li>
</ul>
<ol>
<li><p>可以作为索引的数据结构..</p>
<p>​    <strong><em>Mysq</em></strong>l中索引的使用时，有Hash和二叉树、B树、B+树</p>
<ol>
<li><p>哈希索引</p>
<p>在<strong><em>Mysql</em></strong>中，哈希索引只在Memory引擎中使用显式哈希（在内存，效率较高）。InnoDB支持自适应的哈希。</p>
<p>哈希索引的优点：</p>
<ol>
<li>哈希索引自身只需存储对应的hash值，索引的机构十分紧凑，所以非常快</li>
</ol>
<p>哈希索引的限制：</p>
<ol>
<li>哈希索引只包含哈希值和指针，不存字段</li>
<li>哈希索引的数据不是按照索引值顺序存放，是离散的，所以无法排序</li>
<li>哈希索引不支持部分列查找，需要全部内容来哈希</li>
<li>不支持范围查询</li>
<li>访问虽快，但是哈希碰撞的时候（Java的HashMap中算法叫扰动算法），必须要遍历列表所有指针，逐行检查</li>
<li>碰撞越多，维护成本越大</li>
</ol>
</li>
<li><p>树型索引</p>
<p><strong><em>|1 二叉树</em></strong> </p>
<p>​    <img src="....%5Cimages%5CMysql%E7%B4%A2%E5%BC%95%E6%80%BB%E7%BB%93%5Cimage-20210425215707721.png" alt="image-20210425215707721"></p>
<p><strong><em>|2 红黑树</em></strong></p>
<p>​     <img src="....%5Cimages%5CMysql%E7%B4%A2%E5%BC%95%E6%80%BB%E7%BB%93%5Cimage-20210425215713988.png" alt="image-20210425215713988"></p>
<p>（以上树的节点都会无限加深，会提升IO次数）</p>
<p><strong><em>|3 B-树、B+树</em></strong></p>
<ol>
<li><p>B-树</p>
<p><img src="....%5Cimages%5CMysql%E7%B4%A2%E5%BC%95%E6%80%BB%E7%BB%93%5Cimage-20210425220408425.png" alt="image-20210425220408425"></p>
<p>eg：定位建值为28的数据</p>
<ol>
<li>在第一个块16k的数据找到指针p2（root节点在内存）</li>
<li>读到第二块16k数据找到指针p2</li>
<li>最终找到磁盘块8</li>
</ol>
<ul>
<li>可存储数据 = （假设data一个1k）一块16个索引，16 * 16 * 16 = 4096条，可见是无法满足实际业务需要的，所以B+树就来了</li>
</ul>
</li>
<li><p>B+树     </p>
<p><img src="....%5Cimages%5CMysql%E7%B4%A2%E5%BC%95%E6%80%BB%E7%BB%93%5Cimage-20210425221219820.png" alt="image-20210425221219820"></p>
<ul>
<li>可存储数据为假设key一个10字节 一块16k1600条数据，1600 * 1600 * 16 = 40,960,000条(千万级别)</li>
</ul>
</li>
</ol>
</li>
</ol>
</li>
<li><p><strong><em>B+树</em></strong>在InnoDB中的使用（具体B+树的原理不在这里赘述）</p>
<p><img src="....%5Cimages%5CMysql%E7%B4%A2%E5%BC%95%E6%80%BB%E7%BB%93%5Cclipboard.png" alt="img"></p>
<ul>
<li>优点 -&gt;<ul>
<li>多叉树，多个子节点</li>
<li>叶子节点有序</li>
<li>每个节点可以存多个数据</li>
<li>是一颗平衡二叉树</li>
</ul>
</li>
<li>常见问题 -&gt;</li>
</ul>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">1、mysql的索引一版有几层？</span><br><span class="line">一般情况下，3到4层足以支撑千万级别的表查询，层数是由索引值大小来控制的，所以选取索引的时候一般用占用空间小的</span><br><span class="line"></span><br><span class="line">2、创建索引的字段是长的好，还是短的好？</span><br><span class="line">短的好，因为一块16k，层数不变的情况下，越小存的节点数量越多</span><br><span class="line"></span><br><span class="line">3、创建表的时候用代理主键，还是用自然主键</span><br><span class="line">能使用代理主键尽可能多的使用代理主键</span><br><span class="line"></span><br><span class="line">4、主键设置好，要不要自增？</span><br><span class="line">在满足业务的情况下，尽可能自增，不自增会增加索引维护的成本</span><br><span class="line"></span><br><span class="line">5、分布式应用场景中，自增ID适用吗？</span><br><span class="line">雪花算法 snowflake，自定义id生成器</span><br></pre></td></tr></table></figure>



<p><strong><em>|3. InnoDB下的索引分类</em></strong></p>
<ol>
<li><p><strong>聚镞索引</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&#96;&#96;&#96;规则：主键索引就是聚族索引，必须包含一个主键列，那么key就是主键，如果没有主键，那么key就是唯一键，如果没有唯一键，key就是6字节的rowid</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="2">
<li><p><strong>非聚镞索引</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&#96;&#96;&#96;规则:MYISAM都是非聚镞索引In弄DB的二级索引（辅助、普通索引）</span><br></pre></td></tr></table></figure>

<p><img src="../../images/Mysql%E7%B4%A2%E5%BC%95%E6%80%BB%E7%BB%93/image-20210425182857637.png" alt="image-20210425182857637"></p>
</li>
<li><p><strong>唯一索引</strong>（主键是唯一索引）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">4. **第二索引**(普通索引)</span><br><span class="line"></span><br><span class="line">   &#96;&#96;&#96;InnoDB中，普通索引的规则是，叶子节点存放的是主键的值,不需要回到主键树上去找，这叫做覆盖索引</span><br></pre></td></tr></table></figure>

<p><a href="">回表</a></p>
<p><a href="">索引覆盖</a></p>
</li>
<li><p><strong>组合索引</strong></p>
<p><code>InnoDB中，索引可以是多个值组成的复合索引，也叫组合索引，组合索引必须谈到最左匹配</code></p>
</li>
<li><p><strong>全文索引</strong></p>
<p>​    （用的较少，后面再补充，这是网上博客的一些描述）</p>
<p>　　全文索引的对象是一个“全文集合”，如果对表的多个列建立全文索引，MYSQL就会将这几列拼接成一个字符串，然后进行索引。全文索引实际上也是B+ Tree结构，不过比较特殊，它一共有两层，第一层是所有的关键字，第二层则是每个关键字的一组指文档针，例如 “X” -&gt;行1，行2，行3……。通俗解释全文索引结构就是：它是以关键字去找文档（行），而不是像其他一些索引以行主键来找其他列的内容。要使用全文索引，关于它的几个参数的意义一定要清楚，控制全文索引的参数都是以 ft 开头的（FullText）。查看这些参数以及它们的意义</p>
</li>
</ol>
<p><strong><em>|4. 索引相关概念</em></strong></p>
<ul>
<li>准备： 建立一张名为p，有 id age name address字段的表</li>
</ul>
<ol>
<li>回表</li>
</ol>
<ol start="2">
<li><p>索引覆盖</p>
<ul>
<li>资料：<ul>
<li><a href="https://www.cnblogs.com/happyflyingpig/p/7662881.html" target="_blank" rel="noopener">索引覆盖的概念及其索引优化举例</a></li>
</ul>
</li>
</ul>
</li>
<li><p>最左匹配</p>
</li>
</ol>
<ul>
<li>资料：<ul>
<li><a href="https://zhuanlan.zhihu.com/p/115778804" target="_blank" rel="noopener">知乎关于组合索引最左匹配的描述</a></li>
</ul>
</li>
</ul>
<ol start="4">
<li><p>索引下推</p>
<p>​    </p>
<ul>
<li>资料<ul>
<li><a href="https://zhuanlan.zhihu.com/p/121084592" target="_blank" rel="noopener">知乎：什么是索引下推</a></li>
<li><a href="https://blog.csdn.net/sinat_29774479/article/details/103470244" target="_blank" rel="noopener">博客：图解索引下推</a></li>
</ul>
</li>
</ul>
</li>
<li><p>谓词下推</p>
</li>
</ol>
<p><strong><em>|6.索引优化</em></strong></p>
<ol>
<li><p>MYSQL中Explain语句查看是否有用索引</p>
</li>
<li><p>尽量使用索引</p>
</li>
<li><p>避免回表</p>
</li>
</ol>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/05/07/%E5%B7%A5%E5%85%B7%E5%BA%94%E7%94%A8/MakeFile/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/05/07/%E5%B7%A5%E5%85%B7%E5%BA%94%E7%94%A8/MakeFile/" itemprop="url">Makefile学习</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-05-07T17:22:27+08:00">2021-05-07</time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B7%A5%E5%85%B7%E5%BA%94%E7%94%A8/" itemprop="url" rel="index">
                    <span itemprop="name">工具应用</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h3 id="Makefile"><a href="#Makefile" class="headerlink" title="Makefile"></a>Makefile</h3><hr>
<p>目的：</p>
<ol>
<li>自己能写简单的Makefile。</li>
<li>看懂大神写的Makefile。</li>
</ol>
<ul>
<li>引用自:<a href="https://blog.csdn.net/weixin_38391755/article/details/80380786/" target="_blank" rel="noopener">https://blog.csdn.net/weixin_38391755/article/details/80380786/</a></li>
</ul>
<h4 id="1-Makefile-介绍"><a href="#1-Makefile-介绍" class="headerlink" title="1. Makefile 介绍"></a>1. Makefile 介绍</h4><p>​        一句话概括，<strong>Makefile</strong>作用就是来编译工程的，当然，在Linux系统中，Shell脚本也可以实现这样的功能， 目的是提高开发的效率。</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2021/05/07/%E5%B7%A5%E5%85%B7%E5%BA%94%E7%94%A8/MakeFile/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/04/21/Nosql/Redis-%E8%BF%9B%E9%98%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/04/21/Nosql/Redis-%E8%BF%9B%E9%98%B6/" itemprop="url">Nosql/Redis-进阶</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-04-21T11:55:47+08:00">2021-04-21</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="Redis-进阶"><a href="#Redis-进阶" class="headerlink" title="Redis - 进阶"></a>Redis - 进阶</h3><hr>
<h4 id="一、Redis-配置详解"><a href="#一、Redis-配置详解" class="headerlink" title="一、Redis 配置详解"></a>一、<strong><em>Redis</em></strong> 配置详解</h4><p>​        只说明一些常用的，其他在对Redis深入理解的时候，用到再来看注解。</p>
<ol>
<li>常用配置</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">## INCLUDES </span></span><br><span class="line"><span class="comment">## 标签下可以配置多份config，远程调用，集群时使用</span></span><br><span class="line">	include /path/to/local.conf</span><br><span class="line">	include /path/to/other.conf</span><br><span class="line"></span><br><span class="line"><span class="comment">###1. NETWORK 网络链接</span></span><br><span class="line">    <span class="comment"># bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 		addresses</span></span><br><span class="line">    <span class="comment"># bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv6</span></span><br><span class="line">	<span class="built_in">bind</span> * -::*                     <span class="comment"># 通配符全部ip都可以</span></span><br><span class="line"></span><br><span class="line">	protected-mode yes <span class="comment">##保护模式（默认开启）</span></span><br><span class="line"></span><br><span class="line">	port 6379 <span class="comment">##端口</span></span><br></pre></td></tr></table></figure>

<ol start="2">
<li>重点配置</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">###1. GENERAL</span></span><br><span class="line">	daemonize no <span class="comment">##是否守护进程模式开启，后台运行</span></span><br><span class="line"></span><br><span class="line">	supervised auto</span><br><span class="line"></span><br><span class="line">	pidfile /var/run/redis_6379.pid <span class="comment">### pid文件</span></span><br><span class="line"></span><br><span class="line">	<span class="comment">## 日志级别</span></span><br><span class="line">    <span class="comment"># debug (a lot of information, useful for development/testing)</span></span><br><span class="line">    <span class="comment"># verbose (many rarely useful info, but not a mess like the debug 		level)</span></span><br><span class="line">    <span class="comment"># notice (moderately verbose, what you want in production probably)</span></span><br><span class="line">    <span class="comment"># warning (only very important / critical messages are logged)</span></span><br><span class="line">	loglevel notice</span><br><span class="line"></span><br><span class="line">	logfile <span class="string">""</span> <span class="comment">##日志地址</span></span><br><span class="line">	</span><br><span class="line">	databases 16 <span class="comment">## 数据库数量</span></span><br><span class="line"></span><br><span class="line"><span class="comment">###2. SNAPSHOTTING 快照 - 持久化</span></span><br><span class="line">	<span class="comment">### RDB相关</span></span><br><span class="line">    save 3600 1		<span class="comment">#   * 一小时至少1个key change了</span></span><br><span class="line">    save 300 100	<span class="comment">#   * 五分钟至少100个key change了</span></span><br><span class="line">    save 60 10000	<span class="comment">#   * 六十秒10000个key change了</span></span><br><span class="line">    </span><br><span class="line">	stop-writes-on-bgsave-error yes <span class="comment">#持久化是否继续工作</span></span><br><span class="line"></span><br><span class="line">	rdbcompression yes <span class="comment">#rdb压缩 额外消耗X%的cpu,网上说的是10%</span></span><br><span class="line"></span><br><span class="line">	rdbchecksum yes <span class="comment">#检查rdb</span></span><br><span class="line"></span><br><span class="line">	dbfilename dump.rdb<span class="comment">#rdb 目录</span></span><br><span class="line"></span><br><span class="line"><span class="comment">###3. REPLICATION (特重点，主从复制)</span></span><br><span class="line"></span><br><span class="line"><span class="comment">###4. MEMORY MANAGEMENT</span></span><br><span class="line">	maxmemory &lt;bytes&gt; <span class="comment">##最大内存</span></span><br><span class="line">	</span><br><span class="line">	maxmemory-policy noeviction <span class="comment">## 达到最大内存后的策略</span></span><br><span class="line">	</span><br><span class="line">    <span class="comment"># volatile-lru -&gt; Evict using approximated LRU, only keys with an expire set. </span></span><br><span class="line">    <span class="comment">#删除过期key</span></span><br><span class="line">    <span class="comment"># allkeys-lru -&gt; Evict any key using approximated LRU.</span></span><br><span class="line">    <span class="comment"># volatile-lfu -&gt; Evict using approximated LFU, only keys with an expire set.</span></span><br><span class="line">    <span class="comment"># allkeys-lfu -&gt; Evict any key using approximated LFU.</span></span><br><span class="line">    <span class="comment"># volatile-random -&gt; Remove a random key having an expire set.</span></span><br><span class="line">    <span class="comment"># 随机删除过期的key</span></span><br><span class="line">    <span class="comment"># allkeys-random -&gt; Remove a random key, any key. </span></span><br><span class="line">    <span class="comment"># 随机删除</span></span><br><span class="line">    <span class="comment"># volatile-ttl -&gt; Remove the key with the nearest expire time (minor TTL) </span></span><br><span class="line">    <span class="comment"># 删除临近过期的</span></span><br><span class="line">    <span class="comment"># noeviction -&gt; Don't evict anything, just return an error on write operations. </span></span><br><span class="line">    <span class="comment"># 直接写报错</span></span><br><span class="line"></span><br><span class="line">    maxmemory-eviction-tenacity 10</span><br><span class="line">    </span><br><span class="line"><span class="comment">### 5. APPEND ONLY MODE</span></span><br><span class="line"></span><br><span class="line">	appendonly no <span class="comment">## 默认不开启</span></span><br><span class="line">    </span><br><span class="line">    appendfilename <span class="string">"appendonly.aof"</span> <span class="comment">## 文件名称</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">##同步频率</span></span><br><span class="line">	appendfsync everysec（最多丢失1s的操作）\always\no</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>额外配置</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">## 设置单位，大小写不敏感</span></span><br><span class="line">    1k =&gt; 1000 bytes</span><br><span class="line">    1kb =&gt; 1024 bytes</span><br><span class="line">    1m =&gt; 1000000 bytes</span><br><span class="line">    1mb =&gt; 1024*1024 bytes</span><br><span class="line">    1g =&gt; 1000000000 bytes</span><br><span class="line">    1gb =&gt; 1024*1024*1024 bytes</span><br><span class="line"></span><br><span class="line"><span class="comment">###1. SECURITY</span></span><br><span class="line">	requirepass foobared <span class="comment">#设置密码</span></span><br><span class="line"><span class="comment">###2. CLIENTS</span></span><br><span class="line">	maxclients 10000  <span class="comment">#最大客户端数</span></span><br></pre></td></tr></table></figure>



<h4 id="二、Redis持久化"><a href="#二、Redis持久化" class="headerlink" title="二、Redis持久化"></a>二、<strong><em>Redis</em></strong>持久化</h4><p>​        Redis是内存数据库，但是有些时候数据是需要持久化操作的。Redis提供了RDB和AOF两种方式来持久化。</p>
<ol>
<li><p><strong><em>RDB (Redis Database)</em></strong></p>
<p>（下图是<strong><em>RDB</em></strong>的作用机制）</p>
<p>![xxx](/Users/heyaojia/hill/other/myhexo/source/Redis-基础/截屏2021-04-12 下午10.09.34.png) </p>
<p>​    在指定时间dump到磁盘，Redis会fork一个进程出来持久化，先写到一个临时文件，后面在替换上次持久化的文件。在对数据不敏感的一些业务场景，RDB性能比较好，因为主进程<strong><em>不需要进行任何IO操作</em></strong>。因为如果在最后一次持久化的时候，断电、宕机操作，会丢数据。</p>
</li>
<li><p><strong><em>AOF (Append Of File )</em></strong></p>
<p>​    AOF持久化是以追加操作日志的方式去进行持久化。与RDB相比，AOF的性能消耗会高，但是数据会相较安全。同样，最后一（s）的APPEND操作，假设断电，至少丢失一条数据。</p>
<p>（下图是<strong><em>AOF</em></strong>的作用机制）</p>
</li>
</ol>
<ol start="3">
<li><p>两种方式的<strong><em>触发机制</em></strong></p>
<ol>
<li>RDB相较于AOF的话性能更好，但是数据可靠性偏低</li>
<li>AOF相较于RDB数据完整性高一些，但是性能开销高一点</li>
<li>在实际生产中，AOF、RDB不冲突，可以同时开启</li>
</ol>
</li>
<li><p>数据恢复详情</p>
</li>
</ol>
<h4 id="三、Redis-主从复制"><a href="#三、Redis-主从复制" class="headerlink" title="三、Redis 主从复制"></a>三、<strong><em>Redis</em></strong> <strong>主从复制</strong></h4><p>​        为了打造一个高可用的数据系统，Redis提供了主从复制的机制。</p>
<p><strong><em>| 主从机配置修改</em></strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">pidfile /var/run/redis_6380.pid</span><br><span class="line"></span><br><span class="line">logfile <span class="string">"6380.log"</span></span><br><span class="line"></span><br><span class="line">dbfilename dump6380.rdb</span><br><span class="line"></span><br><span class="line">replicaof localhost 6379</span><br></pre></td></tr></table></figure>

<p><strong><em>| 命令</em></strong></p>
<p>​        <code>INFO REPLICATION</code> 查看节点信息</p>
<p><strong><em>| 数据复制场景</em></strong></p>
<ol>
<li>主机宕机</li>
</ol>
<ol start="2">
<li>从机宕机</li>
</ol>
<ol start="3">
<li>主机宕机重启</li>
</ol>
<ol start="4">
<li>从机宕机重启</li>
</ol>
<p><strong><em>| 主从模式</em></strong></p>
<ol>
<li><p>主 - 从 - 从</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">graph LR</span><br><span class="line">A[主机mater] --&gt;B(从机slave)</span><br><span class="line">A --&gt; C[从机slave]</span><br></pre></td></tr></table></figure>
</li>
<li><p>主 - 从（主） - 从</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">graph LR</span><br><span class="line">A[主机mater] --&gt;B(从机slave)</span><br><span class="line">B --&gt; C[从机slave]</span><br></pre></td></tr></table></figure>
</li>
<li></li>
</ol>
<h4 id="四、Redis哨兵"><a href="#四、Redis哨兵" class="headerlink" title="四、Redis哨兵"></a>四、<strong><em>Redis</em></strong>哨兵</h4><p>​        主从复制中，主Redis节点可写，从节点可读。假设主节点宕机后，只能满足读可用，但是写不可用。哨兵模式正是为了解决这个场景。</p>
<p><strong><em>| 哨兵场景</em></strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">graph LR</span><br><span class="line">A[主机mater] --&gt;B(从机slave)</span><br><span class="line">A --&gt; C[从机slave]	</span><br><span class="line">D[哨兵] --&gt; A</span><br><span class="line">D[哨兵] --&gt; B</span><br><span class="line">D[哨兵] --&gt; C</span><br></pre></td></tr></table></figure>

<p>​    哨兵模式的存在就是为了使Redis有更高的可用性，从Salve中选一个来做Master。哨兵可以是多台，甚至是哨兵集群。多为是心跳检测。</p>
<p><strong><em>| 哨兵选举</em></strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">graph LR</span><br><span class="line">A[主机mater] --&gt;B(从机slave)</span><br><span class="line">A --&gt; C[从机slave]	</span><br><span class="line">D[哨兵] --&gt; A</span><br><span class="line">D --&gt; B</span><br><span class="line">D --&gt; C</span><br><span class="line">E[哨兵] --&gt; A</span><br><span class="line">E[哨兵] --&gt; B</span><br><span class="line">E[哨兵] --&gt; C</span><br><span class="line">E[哨兵] --&gt; D</span><br><span class="line">F[哨兵N个]</span><br></pre></td></tr></table></figure>

<p>如图，假设N个哨兵，链接Master，哨兵1检测到Master已经宕机，这个叫做主官下线，当M个哨兵（M是可以配置的）检测到主机Master下线后，哨兵回进行投票，结果由一个哨兵发起，将执行<code>故障转移</code>操作，通过发布订阅，切换各个哨兵，这叫客观下线。</p>
<p><strong><em>| 哨兵投票算法</em></strong></p>
<p>待补充</p>
<p><strong><em>| 哨兵配置修改</em></strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">filename sentinel.conf</span><br><span class="line"></span><br><span class="line"><span class="comment">### 基础配置</span></span><br><span class="line">port 26379</span><br><span class="line"></span><br><span class="line"><span class="comment">### 监控信息</span></span><br><span class="line"><span class="comment">##sentinel monitor monstername host（不能用localhost） 端口 投票数</span></span><br><span class="line">sentinel monitor myredis 127.0.0.1 6379 1</span><br><span class="line"></span><br><span class="line"><span class="comment">##检测时间可以设置</span></span><br><span class="line">sentinel down-after-milliseconds &lt;master-name&gt; &lt;milliseconds&gt;</span><br><span class="line"></span><br><span class="line"><span class="comment">## failover 时间可以设置</span></span><br><span class="line">sentinel failover-timeout &lt;master-name&gt; &lt;milliseconds&gt;</span><br><span class="line"></span><br><span class="line"><span class="comment">## master down掉后执行通知脚本</span></span><br><span class="line">sentinel notification-script &lt;master-name&gt; &lt;script-path&gt;</span><br><span class="line"></span><br><span class="line"><span class="comment">## master 后执行重新config脚本</span></span><br><span class="line">sentinel client-reconfig-script mymaster /var/redis/reconfig.sh</span><br></pre></td></tr></table></figure>

<p><strong><em>| 启动哨兵</em></strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">redis-sentinel 配置文件</span><br></pre></td></tr></table></figure>

<p>主机宕机</p>
<p><img src="D:%5Chill%5Cmyhexo%5Csource%5Cimages%5CRedis-%E8%BF%9B%E9%98%B6%5Cimage-20210419185629124.png" alt="image-20210419185629124"></p>
<h4 id="五、Redis缓存穿透、击穿"><a href="#五、Redis缓存穿透、击穿" class="headerlink" title="五、Redis缓存穿透、击穿"></a>五、<strong><em>Redis</em></strong>缓存穿透、击穿</h4><p><strong><em>| 缓存穿透</em></strong>（查不到，全部查Mysql）</p>
<p><img src="D:%5Chill%5Cmyhexo%5Csource%5Cimages%5CRedis-%E8%BF%9B%E9%98%B6%5Cimage-20210419191606408.png" alt="image-20210419191606408"></p>
<ul>
<li>解决方案：<ol>
<li>布隆过滤器（后面补充）</li>
<li>设置空缓存并且设置一些过期时间（缺点是牺牲了空间换取性能和高可用）</li>
</ol>
</li>
</ul>
<p><strong><em>| 缓存击穿</em></strong>（相同key量太大）</p>
<p><img src="D:%5Chill%5Cmyhexo%5Csource%5Cimages%5CRedis-%E8%BF%9B%E9%98%B6%5Cimage-20210419192312455.png" alt="image-20210419192312455"></p>
<ul>
<li>解决方案：<ol>
<li>热点数据过期时间设置</li>
<li>分布式锁，限制读写线程数量</li>
</ol>
</li>
</ul>
<h4 id="六、Redis雪崩"><a href="#六、Redis雪崩" class="headerlink" title="六、Redis雪崩"></a>六、<strong><em>Redis</em></strong>雪崩</h4><p>​    缓存雪崩，某一个时间段内，缓存集体失效， 或者Redis宕机！最致命的是Redis宕机或者断网。为了高可用，一版Linux会停掉某些服务，保证主要可用。</p>
<p><strong><em>|redis高可用解决方案</em></strong></p>
<ol>
<li><p>异地多活</p>
<p>多设置几台Redis，集群</p>
</li>
<li><p>限流降级</p>
<p>加锁、或者队列来控制数据写缓存的额线程数量</p>
</li>
<li><p>数据预热</p>
<p>先把可能的数据，先访问一遍，这样大量访问的数据就会在缓存中</p>
</li>
</ol>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/04/01/Nosql/Redis-%E5%9F%BA%E7%A1%80/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/04/01/Nosql/Redis-%E5%9F%BA%E7%A1%80/" itemprop="url">Nosql/Redis-基础</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-04-01T10:48:01+08:00">2021-04-01</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h3 id="Redis-基础"><a href="#Redis-基础" class="headerlink" title="Redis-基础"></a>Redis-基础</h3><hr>
<h4 id="一、准备"><a href="#一、准备" class="headerlink" title="一、准备"></a>一、准备</h4><h5 id="1-MacOS安装"><a href="#1-MacOS安装" class="headerlink" title="1. MacOS安装"></a>1. MacOS安装</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">### 下载包解压后，cd到目录</span></span><br><span class="line">1. make</span><br><span class="line">2. make install</span><br><span class="line">3. mkdir myconfig</span><br><span class="line">4. cp redis.conf myconfig <span class="comment">### 备份一份配置文件，修改相关参数</span></span><br><span class="line">5. 修改myconfig/redis.conf中的daemonize改为yes<span class="comment">### 后台启动</span></span><br><span class="line">6. redis-server myconfig/redis.conf</span><br><span class="line">7. ps -ef |grep redis</span><br><span class="line">8. redis-cli -h localhost -p 6379</span><br><span class="line">9. redis客户端中输入PING</span><br></pre></td></tr></table></figure>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2021/04/01/Nosql/Redis-%E5%9F%BA%E7%A1%80/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/03/30/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E7%9B%B8%E5%85%B3/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E5%AF%BB%E8%B7%AF%E6%80%BB%E7%BB%93/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/03/30/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E7%9B%B8%E5%85%B3/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E5%AF%BB%E8%B7%AF%E6%80%BB%E7%BB%93/" itemprop="url">游戏开发相关/游戏开发寻路总结</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-03-30T11:19:39+08:00">2021-03-30</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h4 id="游戏开发中寻路学习归纳"><a href="#游戏开发中寻路学习归纳" class="headerlink" title="游戏开发中寻路学习归纳"></a>游戏开发中寻路学习归纳</h4><hr>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">###目录：</span></span><br><span class="line">	1.什么是寻路</span><br><span class="line">	2.最基本的寻路</span><br><span class="line">	3.游戏研发中常用的寻路算法归纳</span><br><span class="line">	4.Github上有什么高star的寻路算法</span><br></pre></td></tr></table></figure>

<h5 id="1-寻路"><a href="#1-寻路" class="headerlink" title="1. 寻路"></a>1. 寻路</h5><p>​        寻路顾名思义，就是寻找道路，寻找道路又可以分为寻找正确的道路（不要求快）和寻找一条快速的道路（不一定是最优）。寻路算法是SLG、ARPG游戏中常用功能，该功能的作用是，释放玩家双手，减少繁杂的找寻NPC、地点、任务目标的过程，提高玩家游戏熟悉程度，游戏玩法节奏控制及其效率。虽然在项目中不是我负责寻路模块，但是作为一个游戏研发人员，这是必备技能。</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2021/03/30/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E7%9B%B8%E5%85%B3/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91%E5%AF%BB%E8%B7%AF%E6%80%BB%E7%BB%93/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/03/27/%E6%88%91%E7%9A%84%E9%A1%B9%E7%9B%AE/GO%E5%AE%9E%E7%8E%B0%E6%97%A5%E5%BF%97%E5%BA%93/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/03/27/%E6%88%91%E7%9A%84%E9%A1%B9%E7%9B%AE/GO%E5%AE%9E%E7%8E%B0%E6%97%A5%E5%BF%97%E5%BA%93/" itemprop="url">我的项目/GO实现日志库</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-03-27T11:27:59+08:00">2021-03-27</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="GO实现日志库"><a href="#GO实现日志库" class="headerlink" title="GO实现日志库"></a>GO实现日志库</h3><h4 id="一、前言"><a href="#一、前言" class="headerlink" title="一、前言:"></a>一、前言:</h4><ul>
<li>实现一个配置形式的日志系统，支持多种级别的日志输出</li>
<li>参考Large</li>
<li>参考项目日志输出</li>
</ul>
<h4 id="二、开始："><a href="#二、开始：" class="headerlink" title="二、开始："></a>二、开始：</h4><h5 id="1-知识准备："><a href="#1-知识准备：" class="headerlink" title="1. 知识准备："></a>1. 知识准备：</h5><ol>
<li>GO文件读写</li>
<li>Time库</li>
</ol>
<h5 id="2-需求："><a href="#2-需求：" class="headerlink" title="2. 需求："></a>2. 需求：</h5><ol>
<li>可以输出不同的日志级别</li>
<li>支持配置形式</li>
<li>程序自动准备运行环境，包括配置的缓存，文件创立等</li>
</ol>
<h5 id="3-拓展："><a href="#3-拓展：" class="headerlink" title="3. 拓展："></a>3. 拓展：</h5><ol>
<li>可以热更新配置</li>
</ol>
<h4 id="三、-相关调用"><a href="#三、-相关调用" class="headerlink" title="三、 相关调用"></a>三、 相关调用</h4><h5 id="1-配置文件"><a href="#1-配置文件" class="headerlink" title="1. 配置文件"></a>1. 配置文件</h5><h5 id="2-API调用"><a href="#2-API调用" class="headerlink" title="2. API调用"></a>2. API调用</h5><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">（<span class="number">1</span>）查看系统配置</span><br><span class="line">xxx</span><br><span class="line">（<span class="number">2</span>）修改配置</span><br><span class="line">xxx</span><br><span class="line">（<span class="number">3</span>）输出日志</span><br><span class="line">xxx</span><br></pre></td></tr></table></figure>

<h4 id="四、Issues"><a href="#四、Issues" class="headerlink" title="四、Issues"></a>四、Issues</h4><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/03/27/Go/Basic/Go-%E5%88%87%E7%89%87(slice)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/03/27/Go/Basic/Go-%E5%88%87%E7%89%87(slice)/" itemprop="url">Go/Basic/Go-切片(slice)</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-03-27T11:27:59+08:00">2021-03-27</time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="Go-切片（slice）"><a href="#Go-切片（slice）" class="headerlink" title="Go - 切片（slice）"></a>Go - 切片（slice）</h3><hr>
<h4 id="前言-gt"><a href="#前言-gt" class="headerlink" title="前言 -&gt;"></a>前言 -&gt;</h4><p>在Go中，数组因为要规定长度需要声明所以比较有局限性， 所以一般都会使用切片（Slice）这种数据类型。看输出有点像Eralng中的List结构。Go中的Slice是引用类型。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">// 数组有许多局限性，例如：声明时必须声明长度，不能扩容</span></span><br><span class="line">	<span class="comment">// 定义了形参后，如果超过这个长度，会报错</span></span><br><span class="line">	a1 := [<span class="number">4</span>]<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>&#125;</span><br><span class="line">	a2 := [<span class="number">3</span>]<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>&#125;</span><br><span class="line">	result := arraySum(a1) <span class="comment">//报错</span></span><br><span class="line">	result := arraySum(a2)</span><br><span class="line">	fmt.Printf(<span class="string">"%v \n"</span>, result)</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">arraySum</span><span class="params">(x [3]<span class="keyword">int</span>)</span> <span class="title">int</span></span> &#123;</span><br><span class="line">	sum := <span class="number">0</span></span><br><span class="line">	count := <span class="built_in">len</span>(x)</span><br><span class="line">	<span class="keyword">for</span> i := <span class="number">0</span>; i &lt; count; i++ &#123;</span><br><span class="line">		sum = x[<span class="number">0</span>] + sum</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> sum</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="开始-gt"><a href="#开始-gt" class="headerlink" title="开始 -&gt;"></a>开始 -&gt;</h4><h5 id="切片的声明"><a href="#切片的声明" class="headerlink" title="| 切片的声明"></a>| 切片的声明</h5><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//切片声明1</span></span><br><span class="line"><span class="keyword">var</span> name = []<span class="keyword">string</span>&#123;&#125;</span><br><span class="line"><span class="comment">//切片声明2</span></span><br><span class="line"><span class="keyword">var</span> name = [<span class="number">7</span>]<span class="keyword">string</span>&#123;<span class="string">"初级工程师"</span>, <span class="string">"中级工程师"</span>, <span class="string">"高级工程师"</span>, <span class="string">"架构师"</span>, <span class="string">"项目经理"</span>, <span class="string">"负责人"</span>, <span class="string">"老板"</span>&#125;</span><br><span class="line">slice := name[:] <span class="comment">// 切片表达式 ：表示从 [start 到 end) 左闭右开</span></span><br><span class="line"><span class="comment">//切片声明3</span></span><br><span class="line">slice : = <span class="built_in">make</span>([]T,<span class="built_in">cap</span>,<span class="built_in">len</span>)</span><br></pre></td></tr></table></figure>

<h5 id="切片的用法"><a href="#切片的用法" class="headerlink" title="| 切片的用法"></a>| 切片的用法</h5><p>切片初始化值 -&gt;</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> slice = []<span class="keyword">string</span>&#123;&#125;   <span class="comment">// 声明没有初始化</span></span><br><span class="line"><span class="keyword">var</span> slice = []<span class="keyword">int</span>&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125; <span class="comment">//声明初始化</span></span><br></pre></td></tr></table></figure>

<p>切片的长度、容量 -&gt;</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">fmt.Println(<span class="string">"slice len"</span>, <span class="built_in">len</span>(slice)) <span class="comment">//长度，数组内个数</span></span><br><span class="line">fmt.Println(<span class="string">"slice cap"</span>, <span class="built_in">cap</span>(slice)) <span class="comment">//容量，数组长度</span></span><br></pre></td></tr></table></figure>

<h5 id="切片表达式"><a href="#切片表达式" class="headerlink" title="| 切片表达式"></a>| 切片表达式</h5><p>切片本质是数组，可以基于切片表达式获取到切片；</p>
<ul>
<li>简单表达式</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> slice = []<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>&#125; <span class="comment">// len:6;cap:6</span></span><br><span class="line">subslice  := slice[:]   <span class="comment">//左右不指示值，表示从头到尾 &#123;1, 2, 3, 4, 5, 6&#125;</span></span><br><span class="line">subslice1 := slice[<span class="number">1</span>:<span class="number">3</span>] <span class="comment">//左闭右关[1,3)，表示从下标1 到下标2 &#123;2,3&#125;</span></span><br><span class="line"><span class="comment">// ** 这里注意，subslice1读取了slice的[1,3),表示他访问不到最左边的值了，所以这里cap只能是5</span></span><br></pre></td></tr></table></figure>

<ul>
<li>完整表达式</li>
</ul>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// a[low : high : max]</span></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">	a := [<span class="number">5</span>]<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>&#125;</span><br><span class="line">	t := a[<span class="number">1</span>:<span class="number">3</span>:<span class="number">5</span>]</span><br><span class="line">	fmt.Printf(<span class="string">"t:%v len(t):%v cap(t):%v\n"</span>, t, <span class="built_in">len</span>(t), <span class="built_in">cap</span>(t))</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="切片CRUD"><a href="#切片CRUD" class="headerlink" title="| 切片CRUD"></a>| 切片CRUD</h5><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> name = []<span class="keyword">string</span>&#123;<span class="string">"初级工程师"</span>, <span class="string">"中级工程师"</span>, <span class="string">"高级工程师"</span>, <span class="string">"架构师"</span>, <span class="string">"项目经理"</span>, <span class="string">"负责人"</span>, <span class="string">"老板"</span>&#125;</span><br></pre></td></tr></table></figure>

<p>切片赋值 -&gt;</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1.初始化的赋值</span></span><br><span class="line"><span class="comment">//2.下标取值</span></span><br></pre></td></tr></table></figure>
<p>切片查询 -&gt;</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//切片取值、赋值</span></span><br><span class="line">name1 := name[<span class="number">0</span>] <span class="comment">// 同数组从0开始</span></span><br><span class="line">name[<span class="number">0</span>] := <span class="string">"努力"</span> <span class="comment">//修改的是底层数组的值	</span></span><br><span class="line"><span class="comment">//切片的循环</span></span><br><span class="line"><span class="keyword">for</span> n:= <span class="keyword">range</span> name&#123;</span><br><span class="line">    fmt.Println(<span class="string">"n"</span>)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<center>EXTRA</center>

<hr>
<center> * 使用append追加元素  * </center>



<center> * 切片删除 * </center>

<p>go中没有删除的方法，所以只能用特性去删除 -&gt;</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">	<span class="comment">// 从切片中删除元素</span></span><br><span class="line">	a := []<span class="keyword">int</span>&#123;<span class="number">30</span>, <span class="number">31</span>, <span class="number">32</span>, <span class="number">33</span>, <span class="number">34</span>, <span class="number">35</span>, <span class="number">36</span>, <span class="number">37</span>&#125;</span><br><span class="line">	<span class="comment">// 要删除索引为2的元素</span></span><br><span class="line">	a = <span class="built_in">append</span>(a[:<span class="number">2</span>], a[<span class="number">3</span>:]...)</span><br><span class="line">	fmt.Println(a) <span class="comment">//[30 31 33 34 35 36 37]</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h5 id="切片补充"><a href="#切片补充" class="headerlink" title="| 切片补充"></a>| 切片补充</h5><ol>
<li>切片再切片</li>
</ol>
<h5 id="切片本质"><a href="#切片本质" class="headerlink" title="| 切片本质"></a>| 切片本质</h5><ol>
<li>切片的底层是什么</li>
<li>切片为何可以不用声明长度</li>
<li>切片的一些坑</li>
</ol>
<h6 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h6><p><a href="https://zhuanlan.zhihu.com/p/61121325" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/61121325</a> slice底层</p>
<p><a href="https://www.jianshu.com/p/843aa553b461" target="_blank" rel="noopener">https://www.jianshu.com/p/843aa553b461</a> 一些坑</p>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/02/25/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/read1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/02/25/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/read1/" itemprop="url">B站-普通人如何实现财务自由</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-02-25T12:04:48+08:00">2021-02-25</time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/" itemprop="url" rel="index">
                    <span itemprop="name">阅读记录</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h4 id="B站-普通人如何实现财务自由"><a href="#B站-普通人如何实现财务自由" class="headerlink" title="B站-普通人如何实现财务自由"></a>B站-普通人如何实现财务自由</h4><h5 id="一、法则："><a href="#一、法则：" class="headerlink" title="一、法则："></a>一、法则：</h5><p>威廉班根 4%法则</p>
<h5 id="二、投资方向参考：投资股票指数（需探讨）"><a href="#二、投资方向参考：投资股票指数（需探讨）" class="headerlink" title="二、投资方向参考：投资股票指数（需探讨）"></a>二、投资方向参考：投资股票指数（需探讨）</h5><p>&emsp;待补充</p>
<h5 id="三、方法"><a href="#三、方法" class="headerlink" title="三、方法"></a>三、方法</h5><p>&emsp; 每年从投资中提取不超过4.2%的金额，用来支付生活所需</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2021/02/25/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/read1/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/02/25/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/read2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="heyaojia">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="hill's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2021/02/25/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/read2/" itemprop="url">游戏中玩家的消费观</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-02-25T12:04:48+08:00">2021-02-25</time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/" itemprop="url" rel="index">
                    <span itemprop="name">阅读记录</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h3 id="游戏中玩家的消费观"><a href="#游戏中玩家的消费观" class="headerlink" title="游戏中玩家的消费观"></a>游戏中玩家的消费观</h3><hr>
<p>​        游戏产品培养意识之路笔记，持续输出这样的思考</p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2021/02/25/%E9%98%85%E8%AF%BB%E8%AE%B0%E5%BD%95/read2/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/2/">&lt;i class&#x3D;&quot;fa fa-angle-right&quot;&gt;&lt;&#x2F;i&gt;</a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">heyaojia</p>
              <p class="site-description motion-element" itemprop="description">游戏行业的一枚小鲜肉</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">21</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">5</span>
                  <span class="site-state-item-name">categories</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="git@gitee.com:hillcool/hillcool.git" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-gitee"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">heyaojia</span>

  

  
</div>









        







        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>
























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.0.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.0.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.0.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.0.0"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.0.0"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
